package com.dissertation.config;

import com.dissertation.pojo.Message;
import com.dissertation.utils.AuthUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 异常处理器
 */

@RestControllerAdvice
public class ExceptionResolver {

    Logger logger = LoggerFactory.getLogger( getClass() );

    @ExceptionHandler( Exception.class )
    public Message fail( Exception ex ) {
//        String prefix = String.format( "[%-16s,%-11s]", AuthUtil.getId(), AuthUtil.getUsername() );
//        logger.error( prefix, ex );
        ex.printStackTrace();
        return Message.createErr( ex.getMessage() );
    }


}
